package messages

import (
	
	

	
	
	
	
	
)

// APRep implements RFC 4120 KRB_AP_REP: https://tools.ietf.org/html/rfc4120#section-5.5.2.
type APRep struct {
	PVNO    int                 `asn1:"explicit,tag:0"`
	MsgType int                 `asn1:"explicit,tag:1"`
	EncPart types.EncryptedData `asn1:"explicit,tag:2"`
}

// EncAPRepPart is the encrypted part of KRB_AP_REP.
type EncAPRepPart struct {
	CTime          time.Time           `asn1:"generalized,explicit,tag:0"`
	Cusec          int                 `asn1:"explicit,tag:1"`
	Subkey         types.EncryptionKey `asn1:"optional,explicit,tag:2"`
	SequenceNumber int64               `asn1:"optional,explicit,tag:3"`
}

// Unmarshal bytes b into the APRep struct.
func ( *APRep) ( []byte) error {
	,  := asn1.UnmarshalWithParams(, , fmt.Sprintf("application,explicit,tag:%v", asnAppTag.APREP))
	if  != nil {
		return processUnmarshalReplyError(, )
	}
	 := msgtype.KRB_AP_REP
	if .MsgType !=  {
		return krberror.NewErrorf(krberror.KRBMsgError, "message ID does not indicate a KRB_AP_REP. Expected: %v; Actual: %v", , .MsgType)
	}
	return nil
}

// Unmarshal bytes b into the APRep encrypted part struct.
func ( *EncAPRepPart) ( []byte) error {
	,  := asn1.UnmarshalWithParams(, , fmt.Sprintf("application,explicit,tag:%v", asnAppTag.EncAPRepPart))
	if  != nil {
		return krberror.Errorf(, krberror.EncodingError, "AP_REP unmarshal error")
	}
	return nil
}